//
//  CaiPiaoOrder.m
//  EasyToo
//
//  Created by linshengqin on 13-8-25.
//
//

// 彩票下注
//public static String j016001 = "{"CTSReqBody":{"EntityList":[{"Stake":["07,11,13,22,28,32|15"],"bType":"0","betCount":"1","betMoney":"2","bs":"1","id":"","isAppend":"0","issue":"2012163","lType":"1","pType":"0"}],"Head":{"ChannelID":"72","Transaction":"0","Ver":"1"},"allMoney":"2","cardId":"445122198702096614","type":"card"},"CTSReqHeader":{"Channel":"01","Comment":"","Contacter":"123123","MesgRefID":"10000001000001001069","OrigSender":"10000001,21218CCA77804D2BA1922C33E0151105","ResultCode":"AED9D60AE68326387374BEAB8BEA6F7A","TranCode":"016001","TxAccount":"","TxAmt":"200","TxPage":"1","TxRecordNum":"20","Userid":"2.0.20120412","version":"20130727"}}";

#import "CaiPiaoOrderRequest.h"

@implementation CaiPiaoOrderRequest

- (id)initWithStake:(NSMutableArray*)stakeArray
              BType:(NSString *)bType
           BetCount:(NSString *)betCount
           BetMoney:(NSString *)betMoney
                 BS:(NSString *)bs
           isAppend:(NSString *)isAppend
              Issue:(NSString *)issue
              LType:(NSString *)ltype
              PType:(NSString*)ptype
           allMoney:(NSString*)totalPrice
             CardID:(NSString*)cardID
           Delegate:(id<ServerCommunicationDelegate>)delegate
{
    self = [super init];
    if (self) {
        self.requestName = @"CaiPiaoOrderRequest";
        self.stakeArray = stakeArray;
        self.bType = bType;
        self.betCount = betCount;
        self.betMoney = betMoney;
        self.bs = bs;
        self.isAppend = isAppend;
        self.issue = issue;
        self.lType = ltype;
        self.pType = ptype;
        self.totalPrice = totalPrice;
        self.delegate = delegate;
        self.url = PROTOCOL_ORDER_URL;
        
        NSMutableDictionary *entityDict = [[[NSMutableDictionary alloc] init] autorelease];
        
        [entityDict setObject:self.stakeArray forKey:@"Stake"];
        [entityDict setObject:self.bType forKey:@"bType"];
        [entityDict setObject:self.betCount forKey:@"betCount"];
        [entityDict setObject:self.betMoney forKey:@"betMoney"];
        [entityDict setObject:self.bs forKey:@"bs"];
        [entityDict setObject:@"" forKey:@"id"];
        [entityDict setObject:self.isAppend forKey:@"isAppend"];
        [entityDict setObject:self.issue forKey:@"issue"];
        [entityDict setObject:self.lType forKey:@"lType"];
        [entityDict setObject:self.pType forKey:@"pType"];
        
        NSArray *entityDicList = [[[NSArray alloc] initWithObjects:entityDict, nil] autorelease];
        
        [self.bodyJsonDict setObject:entityDicList forKey:@"EntityList"];
        
        NSMutableDictionary *headDict = [[[NSMutableDictionary alloc] init] autorelease];
        [headDict setObject:@"72" forKey:@"ChannelID"];
        [headDict setObject:@"0" forKey:@"Transaction"];
        [headDict setObject:@"1" forKey:@"Ver"];
        [self.bodyJsonDict setObject:headDict forKey:@"Head"];
        
        
        [self.bodyJsonDict setObject:self.totalPrice forKey:@"allMoney"];
        [self.bodyJsonDict setObject:cardID forKey:@"cardId"];
        [self.bodyJsonDict setObject:@"card" forKey:@"type"];

        [self.headerJsonDict setObject:@"016001" forKey:@"TranCode"];
        
        [self.headerJsonDict setObject:[NSString stringWithFormat:@"%d", self.totalPrice.intValue * 100] forKey:@"TxAmt"];
        
        [self buildJsonRequest];
    }
    return self;
}

@end
